<?php

/**
 * Edit user form.
 *
 * @package    form
 * @subpackage user
 * @version    SVN: $Id: sfPropelFormTemplate.php 6174 2007-11-27 06:22:40Z fabien $
 */
class UserEditForm extends BaseUserForm
{
  public function configure()
  {
    unset($this['salt'], 
          $this['password'], 
          $this['remember'], 
          $this['url'], 
          $this['credential']);
          
  	$this->widgetSchema['file'] = new sfWidgetFormInputFile();        
    $this->validatorSchema['file'] = new sfValidatorFile();
          
    $this->widgetSchema->setNameFormat('user[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);
    
  	$this->embedI18n(LanguagePeer::getCulturesArray());
  	
    $decorator = new myWidgetFormSchemaFormatterDl($this->widgetSchema);
    $this->widgetSchema->addFormFormatter('dl', $decorator); 
    $this->widgetSchema->setFormFormatterName('dl');   
  }

  public function updateObject()
  {
    $object = parent::updateObject();
    
    $filename = str_replace(sfConfig::get('sf_upload_dir').DIRECTORY_SEPARATOR, '', $object->getFile());
    
    myThumbnail::thumbnails($filename, $object, $object);
    
    $object->setFile($filename);
 
    return $object;
  }
}
